package com.qf.bank.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.bank.funapi.api.FunApi;
import com.qf.bank.funapi.po.Fun;
import com.qf.bank.funapi.vo.FunVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Create on 2019/12/6 20:34
 *
 * @author 飞
 */
@Slf4j
@RestController
@RequestMapping("/fun")
public class FunController {

    @Resource
    private FunApi funApi;
    /**
     * 分页查询
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    public Page<Fun> page(FunVo funVo){
        return funApi.page(funVo);
    }
    /**
     * 根据id查询
     * @param
     * @return
     */
    @RequestMapping(value = "/{funId}",method = RequestMethod.GET)
    public Fun getById(@PathVariable("funId")int funId){
        Fun byId = funApi.getById(funId);
        return byId
                ;
    }
    /**
     * 根据id删除
     * @param funId
     * @return
     */
    @RequestMapping(value = "/{funId}",method = RequestMethod.DELETE)
    public Boolean deleteById(@PathVariable("funId")int funId){
        Boolean deleteById = funApi.deleteById(funId);
        return deleteById;
    }
    /**
     * 添加一个功能
     * @param fun
     * @return
     */
    @RequestMapping(value = "/",method = RequestMethod.POST)
    public Boolean getinsert(@RequestBody Fun fun){
        Boolean getinsert = funApi.getinsert(fun);
        return getinsert;
    }
    /**
     * 修改功能
     * @param fun
     * @return
     */
    @RequestMapping(value = "/",method = RequestMethod.PUT)
    public Boolean updateById(@RequestBody Fun fun){
        Boolean updateById = funApi.updateById(fun);
        return updateById;
    }
}
